package org.hot100_2;

public class leetcode74 {
    public boolean searchMatrix(int[][] matrix, int target) {

        int m = matrix.length;
        int n = matrix[0].length;
        int [] nums= new int[m*n];
        int index = 0;
        for (int i = 0; i <m; i++) {
            for (int j = 0; j < n; j++) {
                nums[index] = matrix[i][j];
                index++;
            }
        }

        int left  = 0;
        int right = nums.length-1;

        while (left<=right){
            int mid = (left+right)>>>1;
            if (nums[mid]==target){
                return true;
            }else if (nums[mid]<target){
                left=mid+1;
            }else if (target<nums[mid]){
                right=mid-1;
            }
        }

        return false;
    }
}
